@@ -0,0 +1,3 @@ |
||
1 |
+# Place all the behaviors and hooks related to the matching controller here. |
|
2 |
+# All this logic will automatically be available in application.js. |
|
3 |
+# You can use CoffeeScript in this file: http://coffeescript.org/ |
@@ -0,0 +1,3 @@ |
||
1 |
+# Place all the behaviors and hooks related to the matching controller here. |
|
2 |
+# All this logic will automatically be available in application.js. |
|
3 |
+# You can use CoffeeScript in this file: http://coffeescript.org/ |
@@ -0,0 +1,3 @@ |
||
1 |
+# Place all the behaviors and hooks related to the matching controller here. |
|
2 |
+# All this logic will automatically be available in application.js. |
|
3 |
+# You can use CoffeeScript in this file: http://coffeescript.org/ |
@@ -0,0 +1,3 @@ |
||
1 |
+// Place all the styles related to the agent controller here. |
|
2 |
+// They will automatically be included in application.css. |
|
3 |
+// You can use Less here: http://lesscss.org/ |
@@ -0,0 +1,3 @@ |
||
1 |
+// Place all the styles related to the missions controller here. |
|
2 |
+// They will automatically be included in application.css. |
|
3 |
+// You can use Less here: http://lesscss.org/ |
@@ -0,0 +1,3 @@ |
||
1 |
+// Place all the styles related to the start controller here. |
|
2 |
+// They will automatically be included in application.css. |
|
3 |
+// You can use Less here: http://lesscss.org/ |
@@ -0,0 +1,10 @@ |
||
1 |
+class AgentController < ApplicationController |
|
2 |
+ def current_missions |
|
3 |
+ end |
|
4 |
+ |
|
5 |
+ def choose_mission |
|
6 |
+ end |
|
7 |
+ |
|
8 |
+ def agent_profile |
|
9 |
+ end |
|
10 |
+end |
@@ -0,0 +1,74 @@ |
||
1 |
+class MissionsController < ApplicationController |
|
2 |
+ before_action :set_mission, only: [:show, :edit, :update, :destroy] |
|
3 |
+ |
|
4 |
+ # GET /missions |
|
5 |
+ # GET /missions.json |
|
6 |
+ def index |
|
7 |
+ @missions = Mission.all |
|
8 |
+ end |
|
9 |
+ |
|
10 |
+ # GET /missions/1 |
|
11 |
+ # GET /missions/1.json |
|
12 |
+ def show |
|
13 |
+ end |
|
14 |
+ |
|
15 |
+ # GET /missions/new |
|
16 |
+ def new |
|
17 |
+ @mission = Mission.new |
|
18 |
+ end |
|
19 |
+ |
|
20 |
+ # GET /missions/1/edit |
|
21 |
+ def edit |
|
22 |
+ end |
|
23 |
+ |
|
24 |
+ # POST /missions |
|
25 |
+ # POST /missions.json |
|
26 |
+ def create |
|
27 |
+ @mission = Mission.new(mission_params) |
|
28 |
+ |
|
29 |
+ respond_to do |format| |
|
30 |
+ if @mission.save |
|
31 |
+ format.html { redirect_to @mission, notice: 'Mission was successfully created.' } |
|
32 |
+ format.json { render action: 'show', status: :created, location: @mission } |
|
33 |
+ else |
|
34 |
+ format.html { render action: 'new' } |
|
35 |
+ format.json { render json: @mission.errors, status: :unprocessable_entity } |
|
36 |
+ end |
|
37 |
+ end |
|
38 |
+ end |
|
39 |
+ |
|
40 |
+ # PATCH/PUT /missions/1 |
|
41 |
+ # PATCH/PUT /missions/1.json |
|
42 |
+ def update |
|
43 |
+ respond_to do |format| |
|
44 |
+ if @mission.update(mission_params) |
|
45 |
+ format.html { redirect_to @mission, notice: 'Mission was successfully updated.' } |
|
46 |
+ format.json { head :no_content } |
|
47 |
+ else |
|
48 |
+ format.html { render action: 'edit' } |
|
49 |
+ format.json { render json: @mission.errors, status: :unprocessable_entity } |
|
50 |
+ end |
|
51 |
+ end |
|
52 |
+ end |
|
53 |
+ |
|
54 |
+ # DELETE /missions/1 |
|
55 |
+ # DELETE /missions/1.json |
|
56 |
+ def destroy |
|
57 |
+ @mission.destroy |
|
58 |
+ respond_to do |format| |
|
59 |
+ format.html { redirect_to missions_url } |
|
60 |
+ format.json { head :no_content } |
|
61 |
+ end |
|
62 |
+ end |
|
63 |
+ |
|
64 |
+ private |
|
65 |
+ # Use callbacks to share common setup or constraints between actions. |
|
66 |
+ def set_mission |
|
67 |
+ @mission = Mission.find(params[:id]) |
|
68 |
+ end |
|
69 |
+ |
|
70 |
+ # Never trust parameters from the scary internet, only allow the white list through. |
|
71 |
+ def mission_params |
|
72 |
+ params.require(:mission).permit(:title, :description, :status, :agent_search_start, :agent_search_end) |
|
73 |
+ end |
|
74 |
+end |
@@ -0,0 +1,7 @@ |
||
1 |
+class StartController < ApplicationController |
|
2 |
+ def index |
|
3 |
+ end |
|
4 |
+ |
|
5 |
+ def about |
|
6 |
+ end |
|
7 |
+end |
@@ -0,0 +1,2 @@ |
||
1 |
+module AgentHelper |
|
2 |
+end |
@@ -0,0 +1,2 @@ |
||
1 |
+module MissionsHelper |
|
2 |
+end |
@@ -0,0 +1,2 @@ |
||
1 |
+module StartHelper |
|
2 |
+end |
@@ -0,0 +1,2 @@ |
||
1 |
+class Mission < ActiveRecord::Base |
|
2 |
+end |
@@ -0,0 +1,4 @@ |
||
1 |
+class MissionAgent < ActiveRecord::Base |
|
2 |
+ belongs_to :mission |
|
3 |
+ belongs_to :user |
|
4 |
+end |
@@ -0,0 +1,3 @@ |
||
1 |
+class MissionAgentStep < ActiveRecord::Base |
|
2 |
+ belongs_to :mission_agent |
|
3 |
+end |
@@ -0,0 +1,2 @@ |
||
1 |
+<h1>Agent#agent_profile</h1> |
|
2 |
+<p>Find me in app/views/agent/agent_profile.html.erb</p> |
@@ -0,0 +1,2 @@ |
||
1 |
+<h1>Agent#choose_mission</h1> |
|
2 |
+<p>Find me in app/views/agent/choose_mission.html.erb</p> |
@@ -0,0 +1,2 @@ |
||
1 |
+<h1>Agent#current_missions</h1> |
|
2 |
+<p>Find me in app/views/agent/current_missions.html.erb</p> |
@@ -0,0 +1,15 @@ |
||
1 |
+<%= simple_form_for(@mission) do |f| %> |
|
2 |
+ <%= f.error_notification %> |
|
3 |
+ |
|
4 |
+ <div class="form-inputs"> |
|
5 |
+ <%= f.input :title %> |
|
6 |
+ <%= f.input :description %> |
|
7 |
+ <%= f.input :status %> |
|
8 |
+ <%= f.input :agent_search_start %> |
|
9 |
+ <%= f.input :agent_search_end %> |
|
10 |
+ </div> |
|
11 |
+ |
|
12 |
+ <div class="form-actions"> |
|
13 |
+ <%= f.button :submit %> |
|
14 |
+ </div> |
|
15 |
+<% end %> |
@@ -0,0 +1,6 @@ |
||
1 |
+<h1>Editing mission</h1> |
|
2 |
+ |
|
3 |
+<%= render 'form' %> |
|
4 |
+ |
|
5 |
+<%= link_to 'Show', @mission %> | |
|
6 |
+<%= link_to 'Back', missions_path %> |
@@ -0,0 +1,35 @@ |
||
1 |
+<h1>Listing missions</h1> |
|
2 |
+ |
|
3 |
+<table> |
|
4 |
+ <thead> |
|
5 |
+ <tr> |
|
6 |
+ <th>Title</th> |
|
7 |
+ <th>Description</th> |
|
8 |
+ <th>Status</th> |
|
9 |
+ <th>Agent search start</th> |
|
10 |
+ <th>Agent search end</th> |
|
11 |
+ <th></th> |
|
12 |
+ <th></th> |
|
13 |
+ <th></th> |
|
14 |
+ </tr> |
|
15 |
+ </thead> |
|
16 |
+ |
|
17 |
+ <tbody> |
|
18 |
+ <% @missions.each do |mission| %> |
|
19 |
+ <tr> |
|
20 |
+ <td><%= mission.title %></td> |
|
21 |
+ <td><%= mission.description %></td> |
|
22 |
+ <td><%= mission.status %></td> |
|
23 |
+ <td><%= mission.agent_search_start %></td> |
|
24 |
+ <td><%= mission.agent_search_end %></td> |
|
25 |
+ <td><%= link_to 'Show', mission %></td> |
|
26 |
+ <td><%= link_to 'Edit', edit_mission_path(mission) %></td> |
|
27 |
+ <td><%= link_to 'Destroy', mission, method: :delete, data: { confirm: 'Are you sure?' } %></td> |
|
28 |
+ </tr> |
|
29 |
+ <% end %> |
|
30 |
+ </tbody> |
|
31 |
+</table> |
|
32 |
+ |
|
33 |
+<br> |
|
34 |
+ |
|
35 |
+<%= link_to 'New Mission', new_mission_path %> |
@@ -0,0 +1,4 @@ |
||
1 |
+json.array!(@missions) do |mission| |
|
2 |
+ json.extract! mission, :id, :title, :description, :status, :agent_search_start, :agent_search_end |
|
3 |
+ json.url mission_url(mission, format: :json) |
|
4 |
+end |
@@ -0,0 +1,5 @@ |
||
1 |
+<h1>New mission</h1> |
|
2 |
+ |
|
3 |
+<%= render 'form' %> |
|
4 |
+ |
|
5 |
+<%= link_to 'Back', missions_path %> |
@@ -0,0 +1,29 @@ |
||
1 |
+<p id="notice"><%= notice %></p> |
|
2 |
+ |
|
3 |
+<p> |
|
4 |
+ <strong>Title:</strong> |
|
5 |
+ <%= @mission.title %> |
|
6 |
+</p> |
|
7 |
+ |
|
8 |
+<p> |
|
9 |
+ <strong>Description:</strong> |
|
10 |
+ <%= @mission.description %> |
|
11 |
+</p> |
|
12 |
+ |
|
13 |
+<p> |
|
14 |
+ <strong>Status:</strong> |
|
15 |
+ <%= @mission.status %> |
|
16 |
+</p> |
|
17 |
+ |
|
18 |
+<p> |
|
19 |
+ <strong>Agent search start:</strong> |
|
20 |
+ <%= @mission.agent_search_start %> |
|
21 |
+</p> |
|
22 |
+ |
|
23 |
+<p> |
|
24 |
+ <strong>Agent search end:</strong> |
|
25 |
+ <%= @mission.agent_search_end %> |
|
26 |
+</p> |
|
27 |
+ |
|
28 |
+<%= link_to 'Edit', edit_mission_path(@mission) %> | |
|
29 |
+<%= link_to 'Back', missions_path %> |
@@ -0,0 +1 @@ |
||
1 |
+json.extract! @mission, :id, :title, :description, :status, :agent_search_start, :agent_search_end, :created_at, :updated_at |
@@ -0,0 +1,2 @@ |
||
1 |
+<h1>Start#about</h1> |
|
2 |
+<p>Find me in app/views/start/about.html.erb</p> |
@@ -0,0 +1,2 @@ |
||
1 |
+<h1>Start#index</h1> |
|
2 |
+<p>Find me in app/views/start/index.html.erb</p> |
@@ -1,10 +1,16 @@ |
||
1 | 1 |
AvalancheGame::Application.routes.draw do |
2 |
+ get "start/about" |
|
3 |
+ get "agent/current_missions" |
|
4 |
+ get "agent/choose_mission" |
|
5 |
+ get "agent/agent_profile" |
|
6 |
+ resources :missions |
|
7 |
+ |
|
2 | 8 |
devise_for :users |
3 | 9 |
# The priority is based upon order of creation: first created -> highest priority. |
4 | 10 |
# See how all your routes lay out with "rake routes". |
5 | 11 |
|
6 | 12 |
# You can have the root of your site routed with "root" |
7 |
- # root 'welcome#index' |
|
13 |
+ root 'start#index' |
|
8 | 14 |
|
9 | 15 |
# Example of regular route: |
10 | 16 |
# get 'products/:id' => 'catalog#view' |
@@ -0,0 +1,13 @@ |
||
1 |
+class CreateMissions < ActiveRecord::Migration |
|
2 |
+ def change |
|
3 |
+ create_table :missions do |t| |
|
4 |
+ t.string :title |
|
5 |
+ t.text :description |
|
6 |
+ t.string :status |
|
7 |
+ t.datetime :agent_search_start |
|
8 |
+ t.datetime :agent_search_end |
|
9 |
+ |
|
10 |
+ t.timestamps |
|
11 |
+ end |
|
12 |
+ end |
|
13 |
+end |
@@ -0,0 +1,15 @@ |
||
1 |
+class CreateMissionAgents < ActiveRecord::Migration |
|
2 |
+ def change |
|
3 |
+ create_table :mission_agents do |t| |
|
4 |
+ t.references :mission, index: true |
|
5 |
+ t.text :description |
|
6 |
+ t.string :location |
|
7 |
+ t.text :reward |
|
8 |
+ t.references :user, index: true |
|
9 |
+ t.string :agent_name |
|
10 |
+ t.boolean :anonymous_agent |
|
11 |
+ |
|
12 |
+ t.timestamps |
|
13 |
+ end |
|
14 |
+ end |
|
15 |
+end |
@@ -0,0 +1,14 @@ |
||
1 |
+class CreateMissionAgentSteps < ActiveRecord::Migration |
|
2 |
+ def change |
|
3 |
+ create_table :mission_agent_steps do |t| |
|
4 |
+ t.references :mission_agent, index: true |
|
5 |
+ t.integer :step |
|
6 |
+ t.text :description |
|
7 |
+ t.boolean :completed |
|
8 |
+ t.string :proof_type |
|
9 |
+ t.string :proof |
|
10 |
+ |
|
11 |
+ t.timestamps |
|
12 |
+ end |
|
13 |
+ end |
|
14 |
+end |
@@ -11,7 +11,7 @@ |
||
11 | 11 |
# |
12 | 12 |
# It's strongly recommended that you check this file into your version control system. |
13 | 13 |
|
14 |
-ActiveRecord::Schema.define(version: 20140821183137) do |
|
14 |
+ActiveRecord::Schema.define(version: 20140821183452) do |
|
15 | 15 |
|
16 | 16 |
# These are extensions that must be enabled in order to support this database |
17 | 17 |
enable_extension "plpgsql" |
@@ -29,6 +29,44 @@ ActiveRecord::Schema.define(version: 20140821183137) do |
||
29 | 29 |
add_index "friendly_id_slugs", ["sluggable_id"], name: "index_friendly_id_slugs_on_sluggable_id", using: :btree |
30 | 30 |
add_index "friendly_id_slugs", ["sluggable_type"], name: "index_friendly_id_slugs_on_sluggable_type", using: :btree |
31 | 31 |
|
32 |
+ create_table "mission_agent_steps", force: true do |t| |
|
33 |
+ t.integer "mission_agent_id" |
|
34 |
+ t.integer "step" |
|
35 |
+ t.text "description" |
|
36 |
+ t.boolean "completed" |
|
37 |
+ t.string "proof_type" |
|
38 |
+ t.string "proof" |
|
39 |
+ t.datetime "created_at" |
|
40 |
+ t.datetime "updated_at" |
|
41 |
+ end |
|
42 |
+ |
|
43 |
+ add_index "mission_agent_steps", ["mission_agent_id"], name: "index_mission_agent_steps_on_mission_agent_id", using: :btree |
|
44 |
+ |
|
45 |
+ create_table "mission_agents", force: true do |t| |
|
46 |
+ t.integer "mission_id" |
|
47 |
+ t.text "description" |
|
48 |
+ t.string "location" |
|
49 |
+ t.text "reward" |
|
50 |
+ t.integer "user_id" |
|
51 |
+ t.string "agent_name" |
|
52 |
+ t.boolean "anonymous_agent" |
|
53 |
+ t.datetime "created_at" |
|
54 |
+ t.datetime "updated_at" |
|
55 |
+ end |
|
56 |
+ |
|
57 |
+ add_index "mission_agents", ["mission_id"], name: "index_mission_agents_on_mission_id", using: :btree |
|
58 |
+ add_index "mission_agents", ["user_id"], name: "index_mission_agents_on_user_id", using: :btree |
|
59 |
+ |
|
60 |
+ create_table "missions", force: true do |t| |
|
61 |
+ t.string "title" |
|
62 |
+ t.text "description" |
|
63 |
+ t.string "status" |
|
64 |
+ t.datetime "agent_search_start" |
|
65 |
+ t.datetime "agent_search_end" |
|
66 |
+ t.datetime "created_at" |
|
67 |
+ t.datetime "updated_at" |
|
68 |
+ end |
|
69 |
+ |
|
32 | 70 |
create_table "users", force: true do |t| |
33 | 71 |
t.string "email", default: "", null: false |
34 | 72 |
t.string "encrypted_password", default: "", null: false |
@@ -0,0 +1,19 @@ |
||
1 |
+require 'test_helper' |
|
2 |
+ |
|
3 |
+class AgentControllerTest < ActionController::TestCase |
|
4 |
+ test "should get current_missions" do |
|
5 |
+ get :current_missions |
|
6 |
+ assert_response :success |
|
7 |
+ end |
|
8 |
+ |
|
9 |
+ test "should get choose_mission" do |
|
10 |
+ get :choose_mission |
|
11 |
+ assert_response :success |
|
12 |
+ end |
|
13 |
+ |
|
14 |
+ test "should get agent_profile" do |
|
15 |
+ get :agent_profile |
|
16 |
+ assert_response :success |
|
17 |
+ end |
|
18 |
+ |
|
19 |
+end |
@@ -0,0 +1,49 @@ |
||
1 |
+require 'test_helper' |
|
2 |
+ |
|
3 |
+class MissionsControllerTest < ActionController::TestCase |
|
4 |
+ setup do |
|
5 |
+ @mission = missions(:one) |
|
6 |
+ end |
|
7 |
+ |
|
8 |
+ test "should get index" do |
|
9 |
+ get :index |
|
10 |
+ assert_response :success |
|
11 |
+ assert_not_nil assigns(:missions) |
|
12 |
+ end |
|
13 |
+ |
|
14 |
+ test "should get new" do |
|
15 |
+ get :new |
|
16 |
+ assert_response :success |
|
17 |
+ end |
|
18 |
+ |
|
19 |
+ test "should create mission" do |
|
20 |
+ assert_difference('Mission.count') do |
|
21 |
+ post :create, mission: { agent_search_end: @mission.agent_search_end, agent_search_start: @mission.agent_search_start, description: @mission.description, status: @mission.status, title: @mission.title } |
|
22 |
+ end |
|
23 |
+ |
|
24 |
+ assert_redirected_to mission_path(assigns(:mission)) |
|
25 |
+ end |
|
26 |
+ |
|
27 |
+ test "should show mission" do |
|
28 |
+ get :show, id: @mission |
|
29 |
+ assert_response :success |
|
30 |
+ end |
|
31 |
+ |
|
32 |
+ test "should get edit" do |
|
33 |
+ get :edit, id: @mission |
|
34 |
+ assert_response :success |
|
35 |
+ end |
|
36 |
+ |
|
37 |
+ test "should update mission" do |
|
38 |
+ patch :update, id: @mission, mission: { agent_search_end: @mission.agent_search_end, agent_search_start: @mission.agent_search_start, description: @mission.description, status: @mission.status, title: @mission.title } |
|
39 |
+ assert_redirected_to mission_path(assigns(:mission)) |
|
40 |
+ end |
|
41 |
+ |
|
42 |
+ test "should destroy mission" do |
|
43 |
+ assert_difference('Mission.count', -1) do |
|
44 |
+ delete :destroy, id: @mission |
|
45 |
+ end |
|
46 |
+ |
|
47 |
+ assert_redirected_to missions_path |
|
48 |
+ end |
|
49 |
+end |
@@ -0,0 +1,14 @@ |
||
1 |
+require 'test_helper' |
|
2 |
+ |
|
3 |
+class StartControllerTest < ActionController::TestCase |
|
4 |
+ test "should get index" do |
|
5 |
+ get :index |
|
6 |
+ assert_response :success |
|
7 |
+ end |
|
8 |
+ |
|
9 |
+ test "should get about" do |
|
10 |
+ get :about |
|
11 |
+ assert_response :success |
|
12 |
+ end |
|
13 |
+ |
|
14 |
+end |
@@ -0,0 +1,17 @@ |
||
1 |
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html |
|
2 |
+ |
|
3 |
+one: |
|
4 |
+ mission_agent_id: |
|
5 |
+ step: 1 |
|
6 |
+ description: MyText |
|
7 |
+ completed: |
|
8 |
+ proof_type: MyString |
|
9 |
+ proof: MyString |
|
10 |
+ |
|
11 |
+two: |
|
12 |
+ mission_agent_id: |
|
13 |
+ step: 1 |
|
14 |
+ description: MyText |
|
15 |
+ completed: |
|
16 |
+ proof_type: MyString |
|
17 |
+ proof: MyString |
@@ -0,0 +1,19 @@ |
||
1 |
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html |
|
2 |
+ |
|
3 |
+one: |
|
4 |
+ mission_id: |
|
5 |
+ description: MyText |
|
6 |
+ location: MyString |
|
7 |
+ reward: MyText |
|
8 |
+ user_id: |
|
9 |
+ agent_name: MyString |
|
10 |
+ anonymous_agent: |
|
11 |
+ |
|
12 |
+two: |
|
13 |
+ mission_id: |
|
14 |
+ description: MyText |
|
15 |
+ location: MyString |
|
16 |
+ reward: MyText |
|
17 |
+ user_id: |
|
18 |
+ agent_name: MyString |
|
19 |
+ anonymous_agent: |
@@ -0,0 +1,15 @@ |
||
1 |
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html |
|
2 |
+ |
|
3 |
+one: |
|
4 |
+ title: MyString |
|
5 |
+ description: MyText |
|
6 |
+ status: MyString |
|
7 |
+ agent_search_start: 2014-08-21 15:34:22 |
|
8 |
+ agent_search_end: 2014-08-21 15:34:22 |
|
9 |
+ |
|
10 |
+two: |
|
11 |
+ title: MyString |
|
12 |
+ description: MyText |
|
13 |
+ status: MyString |
|
14 |
+ agent_search_start: 2014-08-21 15:34:22 |
|
15 |
+ agent_search_end: 2014-08-21 15:34:22 |
@@ -0,0 +1,4 @@ |
||
1 |
+require 'test_helper' |
|
2 |
+ |
|
3 |
+class AgentHelperTest < ActionView::TestCase |
|
4 |
+end |
@@ -0,0 +1,4 @@ |
||
1 |
+require 'test_helper' |
|
2 |
+ |
|
3 |
+class MissionsHelperTest < ActionView::TestCase |
|
4 |
+end |
@@ -0,0 +1,4 @@ |
||
1 |
+require 'test_helper' |
|
2 |
+ |
|
3 |
+class StartHelperTest < ActionView::TestCase |
|
4 |
+end |
@@ -0,0 +1,7 @@ |
||
1 |
+require 'test_helper' |
|
2 |
+ |
|
3 |
+class MissionAgentStepTest < ActiveSupport::TestCase |
|
4 |
+ # test "the truth" do |
|
5 |
+ # assert true |
|
6 |
+ # end |
|
7 |
+end |
@@ -0,0 +1,7 @@ |
||
1 |
+require 'test_helper' |
|
2 |
+ |
|
3 |
+class MissionAgentTest < ActiveSupport::TestCase |
|
4 |
+ # test "the truth" do |
|
5 |
+ # assert true |
|
6 |
+ # end |
|
7 |
+end |
@@ -0,0 +1,7 @@ |
||
1 |
+require 'test_helper' |
|
2 |
+ |
|
3 |
+class MissionTest < ActiveSupport::TestCase |
|
4 |
+ # test "the truth" do |
|
5 |
+ # assert true |
|
6 |
+ # end |
|
7 |
+end |